﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MutilLanguage_Search.Data;
namespace MutilLanguage_Search.Data
{
    class Modify
    {
        public static void setSynonyms(string keyword, int count)
        {
            if (!Init.sdSynonyms.ContainsKey(keyword))
            {
                Init.sdSynonyms.Add(keyword, count);
            }
        }
        public static void setTranslate(string keyword, int count)
        {
            if (!Init.sdTranslate.ContainsKey(keyword))
            {
                Init.sdTranslate.Add(keyword, count);
            }
        }
        public static void setLinksSyn(string keyword, string content)
        {
            if (!Init.sdLinksSyn.ContainsKey(keyword))
            {
                Init.sdLinksSyn.Add(keyword, content);
            }
        }
        public static void setLinksTra(string keyword, string content)
        {
            if (!Init.sdLinksTra.ContainsKey(keyword))
            {
                Init.sdLinksTra.Add(keyword, content);
            }
        }
        public static void setKeyWordsSyn(string keyword)
        {
            string key = keyword.ToLowerInvariant();
            if (!Data.Init.htStopWords.ContainsKey(key))
            {
                if (Data.Init.sdKeyWordsSyn.ContainsKey(key))
                    Data.Init.sdKeyWordsSyn[key] = (int)Data.Init.sdKeyWordsSyn[key] + 1;
                else
                    Data.Init.sdKeyWordsSyn.Add(key, 1);
            }
        }
        public static void setKeyWordsTra(string keyword)
        {
            string key = keyword.ToLowerInvariant();
            if (!Data.Init.htStopWords.ContainsKey(key))
            {
                if (Data.Init.sdKeyWordsTra.ContainsKey(key))
                    Data.Init.sdKeyWordsTra[key] = (int)Data.Init.sdKeyWordsTra[key] + 1;
                else
                    Data.Init.sdKeyWordsTra.Add(key, 1);
            }
        }

        internal static void setTopLinksSyn(string link, string keyword)
        {
            string key = keyword.ToLowerInvariant();
            if(Init.sdSynonyms.ContainsKey(key))
                if (Data.Init.sdTopLinksSyn.ContainsKey(link))
                    Data.Init.sdTopLinksSyn[link] = (int)Data.Init.sdTopLinksSyn[link] + 1;
                else
                    Data.Init.sdTopLinksSyn.Add(link, 1);
        }
    }
}
